<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>主页</title>
    <script language="JavaScript" src="/js/jquery-2.1.1.js"></script>
    <script language="JavaScript">
        $(document).ready(function() {
            var uid = "";
            refresh();
            function refresh() {
                var gps = document.getElementById("gpsinfo").value;
                var pt = gps.split(",");
                var lon = pt[0];
                var lat = pt[1];
                alert(lon + ", " + lat);
                $.getJSON( "/search?uid=" + uid + "&lon=" + lon + "&lat=" + lat, function( data ) {
                    //alert(data.uid);
                    uid = data.uid;
                    for (var i = 0; i < data.goods.length; i++) {
                        var goodsItem = data.goods[i];
                        console.log(JSON.stringify(goodsItem));
                    }
                });
            }
            $("#refresh").click(function(event) {
                refresh();
            });
            $("#infocenter").click(function(event) {
                window.location.href = "/owninfo.html?uid=<%=id%>";
            });
        });
    </script>
    <style>
        body {
            background-color: #fff;
            color: #000;
            font-family: Helvetica, Arial, sans-serif;
        }
        h1, h2, h3 {
            margin-bottom: .2em;
        }
        .refresh {
            margin: 0 2em;
        }
        .infocenter {
            margin: 0 1em;
        }
        .highlight {
            background-color: #ccc;
            border: 1px solid #888;
            font-style: italic;
            margin: 0.5em 0;
            padding: 0.5em;
        }
        .goodsList {
            width: 380px;
            background: #333;
            padding: 5px 10px;
        }
        .gpsinfo {
            width: 200px
        }
    </style>
</head>
<body>
    <button id="refresh" class="refresh">刷新</button>
    <button id="infocenter" class="infocenter">个人中心</button>
    <input id="gpsinfo" type="text" class="gpsinfo" value="117.118489,36.694713"/>
    <div id="goodsList"></div>
</body>
</html>